package com.learnkitchen.learnkitchenrecipes;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ProgressBar;
import android.widget.TextView;

/**
 * 加载数据或者加载进度的fragment
 * Created by Administrator on 2017/9/30 0030.
 */

public class ProgressFragment extends DialogFragment {

    private ProgressBar mProgressBar;
    private TextView mProgressText;
    private String mLoadingText;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        getDialog().setCancelable(false);
        View view = inflater.inflate(R.layout.lkr_loading_layout, container, false);
        setStyle(R.style.LKRDialogStyle, android.R.style.Theme_Dialog);
        initView(view);
        return view;
    }

    private void initView(View view) {
        mProgressBar = (ProgressBar) view.findViewById(R.id.progressBar);
        mProgressText = (TextView) view.findViewById(R.id.progress_text);
        if (!TextUtils.isEmpty(getArguments().getString("loading")))
            mProgressText.setText(getArguments().getString("loading"));
    }
}
